#include<iostream>
using namespace std;
class card {
protected:
	int ID;
	char name;
	int balance;
public:
	card(int i, char n, int b) {
		ID = i;
		name = n;
		balance = b;
	}
	void initial(int i, char n, int b) {
		ID = i;
		name = n;
		balance = b;
	}
	int save(int n) {
		if (n <= 0) {
			return -1;
		}
		else {
			balance += n;
			return 1;
		}
	}
	int withdraw(int n) {
		if (n <= 0 || n > balance) {
			return -1;
		}
		else {
			balance -= n;
			return 1;
		}
	}
	virtual void show() {
		cout << ID << '-' << name << '-' << balance << endl;
	}
};
class traffic_card :public card {
protected:
	int Tcounter;
public:
	traffic_card(int i, char n, int b, int t) :card(i, n, b) {
		Tcounter = t;
	}
	int transfer(int n) {
		if (n <= 0 || n > balance) {
			return -1;
		}
		else {
			balance -= n;
			Tcounter += n;
			return 1;
		}
	}
	void show() {
		cout << ID << '-' << name << '-' << balance << '-' << Tcounter << endl;
	}
};
class VIP_card :public card {
protected:
	int Credit;
public:
	VIP_card(int i, char n, int b, int c) :card(i, n, b) {
		Credit = c;
	}
	int over(int n) {
		if (n <= 0 || n > Credit + balance) {
			return -1;
		}
		else {
			n = n - balance;
			balance = 0;
			Credit -= n;
			return 1;
		}
	}
	void show() {
		cout << ID << '-' << name << '-' << balance << '-' << Credit << endl;
	}
};
int main()
{
	int ID, balance, Tcounter, Credit;
	char name;
	cin >> ID >> name >> balance;
	card c1(ID, name, balance);
	cin >> ID >> name >> balance >> Tcounter;
	traffic_card c2(ID, name, balance, Tcounter);
	cin >> ID >> name >> balance >> Credit;
	VIP_card c3(ID, name, balance, Credit);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	c1.save(a);
	c1.save(b);
	c1.withdraw(c);
	c1.withdraw(d);
	c1.show();
	cin >> a >> b >> c >> d;
	c2.save(a);
	c2.withdraw(b);
	c2.transfer(c);
	c2.transfer(d);
	c2.show();
	cin >> a >> b >> c >> d;
	c3.save(a);
	c3.withdraw(b);
	c3.over(c);
	c3.over(d);
	c3.show();
	return 0;
}